<script setup lang="ts">
import { createTextVNode, defineComponent } from 'vue'

import { NDialogProvider, NLoadingBarProvider, NMessageProvider, NModalProvider, NNotificationProvider, useDialog, useLoadingBar, useMessage, useModal, useNotification } from 'naive-ui'

defineOptions({
  name: 'WProvider',
})

const ContextHolder = defineComponent({
  name: 'ContextHolder',
  setup() {
    function register() {
      window.loadingBar = useLoadingBar()
      window.dialog = useDialog()
      window.message = useMessage()
      window.notification = useNotification()
      window.modal = useModal()
    }
    register()
    return () => createTextVNode()
  },
})
</script>

<template>
  <n-loading-bar-provider>
    <n-dialog-provider>
      <n-modal-provider>
        <n-notification-provider>
          <n-message-provider>
            <context-holder />
            <slot></slot>
          </n-message-provider>
        </n-notification-provider>
      </n-modal-provider>
    </n-dialog-provider>
  </n-loading-bar-provider>
</template>

<style scoped></style>
